<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

//微信小程序 测试
Route::namespace('Api')->prefix('test')->group(function (){
    Route::post('getWxCode','InfoController@getCode');

    Route::get('getWxToken','InfoController@getWxToken');

    Route::get('setLog','InfoController@setLog');//日志文件测试

});



Route::namespace('Api')->middleware('cors')->group(function () {
    Route::get('/users','UserController@index')->name('users.index');

    Route::get('/info','UserController@info')->name('users.info');//返回当前用户信息
    Route::get('/setToken','UserController@setToken')->name('users.setToken');//返回当前用户 jwt token
 //   Route::get('users/{user}','UserController@show')->where('user','.*$')->name('users.show');
//    Route::get('users/{user}','UserController@show')->name('users.show');
//    Route::post('/users','UserController@store')->name('users.store');//注册
//    Route::post('/login','UserController@login')->name('users.login');//登录



    // 第三方登录  微信 公众号
    Route::post('socials/{social_type}/authorizations', 'AuthorizationsController@socialStore')
        ->where('social_type', 'weixin')
        ->name('socials.authorizations.store');

    //微信小程序 授权登录
    Route::post('weixin/mini/authorizations','WxMiniController@getWxMiniOpenid')->name('wxMini.openid');

    //获取小程序用户信息
    Route::post('weixin/mini/getUserMsg','UserController@getUserMsg')->name('wxMini.getUserMsg');

    //获取'jwt'token(前端)
    Route::get('getToken','TokenController@getToken')->name('get.token');

    //微信订阅消息
    Route::get('setSubMsg','Wechat\MessagesController@setSubMsg')->name('set.subscribe.message');
    Route::post('getSubMsg','Wechat\MessagesController@getSubMsg')->name('get.subscribe.message');
});

/**
 *
 */
Route::namespace('Api\Sign')->prefix('sign')->middleware('cors')->group(function (){

    //weixin pay
    Route::get('wxpay','WxPayController@getPayMsg');//微信支付

    Route::get('notify','WxPayController@getNotifyMsg');//微信支付回调页面测试

    //获取报考专业信息（联动）
    Route::get('projectMessage','ProjectController@getProjectMsg')->name('project.message');

    /**
     * 个人中心 User
     */
    Route::namespace('User')->prefix('user')->group(function (){

        //编辑个人资料
        Route::post('uploadAvatar','EditController@uploadAvatar')->name('user.upload');//上传头像 测试
//        Route::post('updateMsg','EditController@updateMsg')->name('user.update');//更新(update)并上传个人信息  token

        //逐条更新
        Route::post('uploadAvatarWx','EditController@uploadAvatarWx')->name('user.upload');//上传头像
        Route::post('editMsg','EditController@editUserMsg')->name('user.edit');//edit 获取用户个人信息    token
        Route::post('uploadName','EditController@uploadName')->name('user.upload.name');//更新昵称
        Route::post('uploadSex','EditController@uploadSex')->name('user.upload.sex');//更新性别
        Route::post('uploadIdentity','EditController@uploadIdentity')->name('user.upload.identity');//更新身份证号码
        Route::post('uploadPhone','EditController@uploadPhone')->name('user.upload.phone');//更新手机号码

    });




    //使用 api-jwt中间件
    Route::middleware('api.refresh')->group(function (){

        //weixin pay
//        Route::get('wxpay','WxPayController@getPayMsg');

        //前端个人信息展示
        Route::post('info','UserController@info')->name('users.login');//获取当前用户信息

        //用户填写个人信息 （前端弹窗提示：首次注册用户填写，与老师填写的报考信息绑定）
        Route::post('userAdd','UserController@userAdd')->name('user.add.user');//添加用户信息（用户填报个人信息），与users表对应

        //project  根据对应信息支付
        Route::post('userAddProject','UserController@userAddProject')->name('user.add.project');//用户填报信息：与老师填报的报考专业对应

        //获取用户的微信信息
        Route::post('addUserMsg','UserController@addUserMsg')->name('user.add.wxMsg');

    });


    //使用 wx-open 中间件
    Route::middleware('wx.open')->prefix('wx')->group(function (){

        //前端个人信息展示
        Route::post('info','UserWxController@info')->name('users.wx.login');//获取当前用户信息

        //用户填写个人信息 （前端弹窗提示：首次注册用户填写，与老师填写的报考信息绑定）
        Route::post('userAdd','UserWxController@userAdd')->name('user.add.wx.user');//添加用户信息（用户填报个人信息），与users表对应

    });


});

/**
 * 梦想学院
 */

Route::namespace('Api\Dream')->prefix('dream')->group(function (){
    Route::get('navigation','HomeController@getNavigation');//导航栏
    Route::post('banner','HomeController@getBanner');//banner图

    //
    Route::get('testInto','IntoController@testInto');


    /**
     * 视频板块
     */
    Route::prefix('video')->group(function (){

        Route::post('new','VideoController@getNew');//最新直播课程
        Route::post('detail','VideoController@getDetail');//详情

//        Route::post('category','VideoController@getCategory');//分类视频
        Route::post('branch','VideoController@getBranch');//对应视频详情(具体视频分支)，获取观众数
        Route::post('comment','VideoController@getComments');//获取视频评论
        Route::post('addComment','VideoController@addComment')->name('add.comment');//用户发部评论  token

        //2.0版本
        Route::prefix('v2')->group(function (){

            Route::any('category','VideoController@getTwoCategory');//分类视频
            Route::post('list','VideoController@getList')->name('video.get.list');//视频列表
            Route::post('detail','VideoController@getTwoDetail')->name('video.get.detail');//视频详情
        });



     });




    /**
     * 社区版块
     */
    Route::namespace('Content')->prefix('content')->group(function (){

        //研博圈展示 community:社区
        Route::namespace('Community')->prefix('community')->group(function (){
            Route::get('create','CommunityController@create')->name('community.create');//获取所有研博圈信息，用于展示
            Route::post('store','CommunityController@store')->name('community.store');//新增内容
            Route::post('manyImage','CommunityController@contentImage')->name('community.add.image');//对应内容的多图上传


        });


        //问答 question
    });


    /**
     * 小程序2.0
     */
    //活动
    Route::namespace('Activity')->prefix('activity')->group(function (){
        Route::get('activityMsg','HomeController@activityMsg')->name('activity.index');//首页活动展示
        Route::get('nowMsg','HomeController@nowMsg')->name('activity.home.now');//正在进行的活动
        Route::get('pastMsg','HomeController@pastMsg')->name('activity.home.past');//往期活动

        Route::get('contentType','AboutController@contentType')->name('activity.about.type');//具体活动

        //双色球活动详情
        Route::namespace('About')->prefix('sphere')->group(function (){

            Route::post('contentMsg','SphereController@contentMsg')->name('activity.about.sphere.content');//活动页详情（内容）
//            Route::get('successCode','SphereController@successCode')->name('activity.about.sphere.successCode');//中奖码

            //关于抽奖
            Route::post('userGetCode','SphereController@userGetCode')->name('sphere.user.getCode');//用户抽奖：获取抽奖码
            Route::post('getShareNumber','SphereController@getShareNumber')->name('sphere.share.getNumber');//用户分享获取抽奖机会

            //记录
            Route::post('getUserCodeMsg','SphereController@getUserCodeMsg')->name('sphere.code.msg');//用户抽奖记录
            Route::post('showUserCodes','SphereController@showUserCodes')->name('sphere.show.codes');//查看我的抽奖码
            Route::post('lastSuccessCode','SphereController@lastSuccessCode')->name('sphere.last.code');//上期中奖号码

            //兑奖（中奖码）
            Route::post('prizeEvent','SphereController@prizeEvent')->name('sphere.prize.event');//获取中奖码并存储中奖者:后台操作

            Route::get('pushMsg','SphereController@pushMsg')->name('activity.sphere.pushMsg');//消息推送（消息订阅）,api测试
            Route::get('pushToken','SphereController@pushToken')->name('activity.sphere.pushToken');//消息推送（消息订阅）,token检测，
        });
    });

        /**
         * 分享奖励金
         */





});



